<#include "../../common/header.htm">
<div class="content-wrapper">
	<section class="content" id="holidayDialog">
		<form id="caseManageform" method="post" class="form-horizontal"  style="width: 500px;">
			<div class="form-group">
				<label  class="col-sm-3 control-label"><span class="casestar">*</span>假日名称：</label>
				<div class="col-sm-8 casexiaqu">
					<input  v-model="holidayName" class="form-control easyui-validatebox" data-options="required:true,validType:['length[1,100]']"/>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">日期：</label>
				<div class="col-sm-6">
					<input id="date">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">误差天数：</label>
				<div class="col-sm-8 casexiaqu">
					<input onkeyup="this.value=this.value.replace(/\D/g,'')" v-model="errorDays"  class="form-control easyui-validatebox"/>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">日期类型：</label>
				<div class="col-sm-8 casexiaqu">
					<!--<input v-model="dateType"  class="form-control easyui-validatebox"/>-->
					<el-select v-model="dateType" placeholder="请选择">
						<el-option
								key="阳历"
								label="阳历"
								value="阳历">
						</el-option>
						<el-option
								key="阴历"
								label="阴历"
								value="阴历">
						</el-option>
					</el-select>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">启用状态：</label>
				<div class="col-sm-8">
					<input v-model="status"  type="radio"  value="1"><span class="casetypespan">启用</span>
					<input v-model="status"  type="radio"  value="0"><span class="casetypespan">不启用</span>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">备注：</label>
				<div class="col-sm-8">
					<textarea  v-model="remark" style="width: 400px;height: 100px;" data-options="validType:['length[1,1000]']"></textarea>
				</div>
			</div>
			<div class="form-group bill-buttonarea"  style="text-align: center;">
				<input type="button" class="btn btn-primary" @click="onSubmit" value="提交" />
			</div>
		</form>
	</section>
</div>
<script>

	$(function () {
		var data=top.dialog.get(window).data
		var id=data.id;
		if (id){
			$.ajax({
				url:"${ctx}/holiday/findOneById",
				type: "post",
				data: {
					id:id,
				},
				dataType: "json",
				success: function (msg) {
					if (msg.flag) {
						var obj=msg.data;
						vm.holidayName=obj.holidayName
						vm.dateType=obj.dateType
						vm.remark=obj.remark
						vm.status=obj.status
						vm.errorDays=obj.errorDays
						vm.id=obj.id
						$('#date').datebox({
							required:false,
							editable:false,
							width:'45%',
						}).datebox("setValue",formatDate( new Date(obj.holidayDate),'yyyy-MM-dd hh:mm:ss'));
					}
				},

			})
		}else{
			$('#date').datebox({
				required:false,
				editable:false,
				width:'45%',
			}).datebox("setValue",formatDate( new Date(),'yyyy-MM-dd hh:mm:ss'));
		}
	})
	var vm=new Vue({
		el:"#holidayDialog",
		data:{
			holidayName:"",
			errorDays:"",
			dateType:"",
			remark:"",
			status:"1"
		},
		methods:{
			onSubmit(){
				$.ajax({
					url:"${ctx}/holiday/save",
					type: "post",
					data: {
						id:this.id,
						holidayName:this.holidayName,
						errorDays:this.errorDays,
						dateType:this.dateType,
						remark:this.remark,
						status:this.status,
						holidayDateTemp:$("#date").val()
					},
					dataType: "json",
					success: function (msg) {
						if (msg.flag) {
							if (vm.id){
								vm.$message('修改成功');
							} else{
								vm.$message('新增成功');
							}
							//top.dialog({id:"test"}).close()
						}
					},
				})
			},

		}
	})



</script>
<style>
	.bill-buttonarea .btn{
		background: #4595ec;
		border-color: transparent;
	}
	.bill-buttonarea .btn:hover{
		background: #3296f1;
	}
	.btn-primary:active:focus{
		background: #0c76d7;
	}
	.casetypespan{
		cursor: pointer;
	}
	#caseRemark{
		border-radius: 4px;
		border: solid 1px #d9d9d9;

	}
	sapn.caseperfen {
		margin-left: 25px;
		height: 34px;
		line-height: 34px;
	}
	.col-sm-8{
		padding-left: 0;
	}
	.col-sm-6{
		padding-left: 0;
	}
	#personName{
		width: 527px;
		height: 34px;
		background-color: #ffffff;
		border-radius: 4px;
		border: solid 1px #d9d9d9;
	}
	input#caseAuthority{
		margin-right: 6px;
	}
	input#casePerson {
		margin-right: 6px;
	}
	span.casetypespan {
		margin-right: 35px;
	}
	input#caseType {
		margin-right: 6px;
	}
	.casetypec{
		margin-top: 5px;
	}
	.form-group {
		margin-bottom: 25px;
	}
	span.casestar {
		color: red;
		font-size: 18px;
		position: absolute;
		right: 86px;
		top: 8px;
		font-weight: 900;
	}
	label.col-sm-3.control-label {
		font-weight: normal;
		color: #000;
	}
	.box-body {
		margin-top: 30px;
	}
	.box-body.table-responsive {
		height: 100%;
	}
	.fixed-table-pagination {
		margin-top: 15px;
	}
	.form-control {
		width: 666px;
		height: 34px;
		line-height: 25px;
		background: #fff;
		border-color: #d9d9d9;
		border-radius: 4px;
	}
	.el-select-dropdown__wrap{
		overflow: hidden;
	}
</style>